Skip to content

[Repo Assist] Add MarkdownProvider type provider#1661

Closed
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/feature-markdown-provider-ff1df2a-e85a218396c16e29
Closed

[Repo Assist] Add MarkdownProvider type provider#1661
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/feature-markdown-provider-ff1df2a-e85a218396c16e29

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist.

Implements a MarkdownProvider type provider that gives statically typed access to YAML front matter in Markdown files, as requested in #1657.

What this adds

type Post = FSharp.Data.MarkdownProvider<"post.md">

// Given a file with YAML front matter:
// ---
// title: Hello World
// date: 2024-01-15
// author: Jane Doe
// tags: [fsharp, data]
// draft: false
// views: 1234
// rating: 4.5
// ---
// # Body content here

let post = Post.Load("post.md")
post.Title   // string:   "Hello World"
post.Date    // DateTime: 2024-01-15
post.Author  // string:   "Jane Doe"
post.Tags    // string[]: [| "fsharp"; "data" |]
post.Draft   // bool:     false
post.Views   // int:      1234
post.Rating  // decimal:  4.5m
post.Body    // string:   "# Body content here\n..."

// Also: Parse, AsyncLoad, With* methods

Implementation

src/FSharp.Data.Json.Core/MarkdownDocument.fs (new)

  • MarkdownDocument type that implements IJsonDocument, carrying both the front-matter JsonValue and the Body string
  • FrontMatterParser internal module: minimal YAML-lite parser supporting strings, numbers, booleans, null, inline arrays [a, b, c], and block arrays (- item style)
  • MarkdownDocument.Load(TextReader) and MarkdownDocument.ParseSample(string) static methods

src/FSharp.Data.DesignTime/Markdown/MarkdownProvider.fs (new)

  • MarkdownProvider type provider registered as FSharp.Data.MarkdownProvider
  • At design time: parses sample front matter → JsonValue.Record → runs through existing JsonInference + JsonTypeBuilder
  • Adds a Body: string property to the root generated type (via IJsonDocument :?> MarkdownDocument downcast — safe because CreateFromTextReader always produces a MarkdownDocument)
  • Static parameters: Sample, RootName, Culture, Encoding, ResolutionFolder, EmbeddedResource, InferTypesFromValues, UseOriginalNames, PreferOptionals

Tests & docs

  • tests/FSharp.Data.Tests/Data/BlogPost.md — sample file
  • tests/FSharp.Data.DesignTime.Tests/expected/Markdown,BlogPost.md,,True.expected — signature snapshot
  • tests/FSharp.Data.Tests/MarkdownProvider.fs — integration tests (7 test cases)
  • docs/library/MarkdownProvider.fsx — documentation

Design decisions

  • Reuse JSON infrastructure: the front matter is treated as a JSON record internally, so all the existing type inference, property generation, With* methods, and InferenceMode support come for free.
  • No new dependencies: the YAML parser is a simple ~80-line F# implementation covering the subset of YAML used in markdown front matter.
  • Body always available: the Body property is added to the root type after JSON type generation, giving access to the markdown content below the front matter.

Supported front matter patterns

YAML F# type
key: value string
key: 42 int
key: 3.14 decimal
key: true / false bool
key: 2024-01-15 System.DateTime
key: [a, b, c] string[]
key: null / ~ T option
Block array - item string[]

Test Status

✅ Build succeeded
✅ 488 design-time tests pass (including new Markdown signature test)
⚠️ FSharp.Data.Tests OOM on CI runner — pre-existing infrastructure constraint (confirmed by checking out main and observing the same failure without my changes)

Closes #1657

Generated by Repo Assist

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@f2c5cf1e4af58e09a93ba0703c6bf084711b265f. View source at https://github.com/githubnext/agentics/tree/f2c5cf1e4af58e09a93ba0703c6bf084711b265f/workflows/repo-assist.md.

…ter in Markdown files

- Add MarkdownDocument runtime type (FSharp.Data.Json.Core) implementing IJsonDocument
  with a minimal YAML-lite front matter parser and Body property
- Add MarkdownProvider design-time type provider (FSharp.Data.DesignTime) reusing
  existing JSON inference and type-generation infrastructure
- Add sample data file (BlogPost.md) and design-time signature test
- Add integration tests for MarkdownProvider
- Add documentation (docs/library/MarkdownProvider.fsx)
- Update RELEASE_NOTES.md

Closes #1657

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme
Copy link
Copy Markdown
Contributor

dsyme commented Feb 26, 2026

Great job but the use cases are not so compelling

@dsyme dsyme closed this Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Markdown type provider

1 participant